import { request, GET, POST } from '../utils/request';
import { getCookies } from '../utils/cookie'

export function getStatusList() {
  const { userid, token } = getCookies();
  if (!token) return;
  const headers = {
    'Authorization': `Bearer ${token}`
  }
  return GET(`/api/v1/status`, headers);
}

export function getStatusGroupList(group) {
  const { userid, token } = getCookies();
  if (!token) return;
  const headers = {
    'Authorization': `Bearer ${token}`
  }
  return GET(`/api/v1/status?group=${group}`, headers);
}

export function getStatus() {
  const { userid, token } = getCookies();
  if (!token) return;
  const headers = {
    'Authorization': `Bearer ${token}`
  }
  return GET(`/api/v1/status/${userid}`, headers);
}

export function setStatus(status) {
  const { userid, username, group, token } = getCookies();
  if (!token) return;
  const headers = {
    'Authorization': `Bearer ${token}`
  }
  return GET(`/api/v1/status/new?userid=${userid}&username=${username}&group=${group}&status=${status}`, headers);
}

